/*
 SGSortingGameLevel.m
 Date Created: March 6, 2010
 
 Authors: Karanvir Gill <viper1029@gmail.com>
          Frank Lau <flaua@sfu.ca>
 
 Copyright (C) 2010 Green-Power
 
 URL: http://code.google.com/p/green-power
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 $Id$
 */

#import "SGSortingGameLevel.h"
#import "SGRecyclableType.h"

@implementation SGSortingGameLevel
@synthesize levelNumber;
@synthesize speedOfItems;
@synthesize numberOfItemsInLevel;
@synthesize livesLeft;


- (SGSortingGameLevel*)initWithLevel:(NSUInteger)level {
	self = [super init];
	if( self ) {
		levelNumber = level;
		speedOfItems = CGPointMake(0,pow(1.15,levelNumber-1)); //no x movement
		numberOfItemsInLevel = 15+3*(levelNumber-1); 
	}
	return self;
}

- (NSArray *)listItemsInLevel {
	if(levelNumber == 1){
		NSRange itemRange;
		itemRange.location=0;
		itemRange.length = 4;	
		
		NSArray *avaliableRecyclableTypes = [SGRecyclableType listOfficialTypes];
		//items 0 to 4 are used in level 1
		NSArray *itemsinLevel = [avaliableRecyclableTypes subarrayWithRange:itemRange];
		[avaliableRecyclableTypes release];
		return itemsinLevel;
	}
	
	if(levelNumber == 2){
		NSRange itemRange;
		itemRange.location=0;
		itemRange.length = 6;
		
		NSArray *avaliableRecyclableTypes = [SGRecyclableType listOfficialTypes];
		//items 0 to 6 are used in level 2, etc.
		NSArray *itemsinLevel = [avaliableRecyclableTypes subarrayWithRange:itemRange];
		[avaliableRecyclableTypes release];
		return itemsinLevel;
	}
	
	if(levelNumber == 3){
		NSRange itemRange;
		itemRange.location=0;
		itemRange.length = 8;
		
		NSArray *avaliableRecyclableTypes = [SGRecyclableType listOfficialTypes];
		NSArray *itemsinLevel = [avaliableRecyclableTypes subarrayWithRange:itemRange];
		[avaliableRecyclableTypes release];
		return itemsinLevel;
	}
	
	if(levelNumber == 4){
		NSRange itemRange;
		itemRange.location=0;
		itemRange.length = 10;
		
		NSArray *avaliableRecyclableTypes = [SGRecyclableType listOfficialTypes];
		NSArray *itemsinLevel = [avaliableRecyclableTypes subarrayWithRange:itemRange];
		[avaliableRecyclableTypes release];
		return itemsinLevel;
	}
	
	if(levelNumber >= 5){
		NSRange itemRange;
		itemRange.location=0;
		itemRange.length = 12;
		
		NSArray *avaliableRecyclableTypes = [SGRecyclableType listOfficialTypes];
		NSArray *itemsinLevel = [avaliableRecyclableTypes subarrayWithRange:itemRange];
		[avaliableRecyclableTypes release];
		return itemsinLevel;
	}
	
		
	return nil;
}

@end
